<!DOCTYPE html>
<html>

<head>
	<title>医院风采</title>
</head>

<body>
	<div class="container-fluid">
		<div class="card">
			<header class="card-header">
				<div class="card-title">个人信息</div>
			</header>
			<div class="card-body">
				<div class="d-flex">
					<img src="/admin/images/profile_male.jpg" alt="..." class="avatar-xl rounded-circle me-3">
					<div class="flex-grow-1 mx-3">
						<h2 style="padding-top: 10px;;font-size: 20px;" id="username">admin</h2>
						<p style="padding-top: 10px;margin-top: 10px;font-size: 13.5px;">China ， 中国</p>
					</div>
				</div>
				<br>
				<form class="needs-validation " novalidate id="dialogForm">
					<input type="text" name="id" hidden>
					<div class="row mb-3">
						<label for="username" class="col-form-label  required">用户名</label>
						<input type="text" class="form-control" name="username" required disabled>
					</div>
					<div class="row mb-3">
						<label for="mobile" class="col-form-label  required">电话</label>
						<input type="text" class="form-control" name="mobile" required phone=true>
					</div>
					<div class="row mb-3">
						<label for="email" class="col-form-label ">邮箱</label>
						<input type="email" class="form-control" name="email" email>
					</div>
					<div class="row mb-3">
						<label for="password" class="col-form-label">密码</label>
						<input type="password" class="form-control" name="password" id="password">
					</div>
					<div class="row mb-3">
						<label for="repassword" class="col-form-label">确认密码</label>
						<input type="password" class="form-control" name="repassword" equalTo=#password>
					</div>
					<div class="row">
						<div class="col-md-4">
							<button type="submit" class="btn btn-primary">保存</button>
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
</body>

</html>
<script type="module">
	import admin from "/admin/js/admin.js"
	var layer = admin.getModule("layer");
	var request = admin.getModule("request");
	var button = admin.getModule("button");
	var form = admin.getModule("form");

	var userInfo = JSON.parse(sessionStorage.getItem("userInfo"))
	$("#username").text(userInfo.username);
	form.val("#dialogForm", userInfo)

	$("#dialogForm").submit(function () {
		var btn = button.load({elem: "#dialogForm button[type='submit']"});
		if (!form.validate($(this))) {
			btn.stop();
			return false;
		}
		var data = form.val("#dialogForm");
		request.postAlert('user/editSelf', data).then(res => {
			btn.stop();
		}).catch(err => {
			btn.stop();
		})
		return false;
	})

</script>

</html>